package com.testcolision.simulation;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
 

public class SoreteMalCagado {

	// positionX, positionY - where the car is
	// velocityX, velocityY - speed on each axis
	// drag - how fast the car slows down
	// angle - the rotation of the car, in radians
	// angularVelocity - speed the car is spinning, in radians
	// angularDrag - how fast the car stops spinning
	// power - how fast car can accelerate
	// turnSpeed - how fast to turn

	public Vector2 position = new Vector2(0, 0);
	public Vector2 velocity = new Vector2(0, 0);
	public float drag = 0.90f;
	public float angle = 90;
	public float angularVelocity = 0;
	public float angularDrag = 0.92f;
	public float power = 2f;
	public float turnSpeed = 0.2f;

	public SoreteMalCagado() {
		// TODO Auto-generated constructor stub
	}

	public void update(float delta) {
		position.x += velocity.x * delta;
		position.y += velocity.y * delta;
		velocity.x *= drag;
		velocity.y *= drag;
		angle += angularVelocity;
		angularVelocity *= angularDrag;
	}

	public void accelerate() {
		velocity.x -= MathUtils.sinDeg(angle) * power;
		velocity.y -= MathUtils.cosDeg(angle) * power;
	}

	public void steer(float steering) {
		angularVelocity -= turnSpeed*steering;
	}
}
